package com.export.rowmapper;

import com.export.bean.DeviceKvHistoryModel;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;

/**
 * Created by MeowParse on 2017/5/9.
 *
 */
public class DeviceKvHistoryRowMapper implements RowMapper<DeviceKvHistoryModel>  {

    SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        @Override
        public DeviceKvHistoryModel mapRow(ResultSet rs, int rowNum) throws SQLException {

            DeviceKvHistoryModel deviceKvHistoryModel = new DeviceKvHistoryModel();
            deviceKvHistoryModel.setCreated(sdf.format(rs.getTimestamp("created")));
            deviceKvHistoryModel.setDeviceId(rs.getString("device_id"));
//            deviceKvHistoryModel.setDeviceId(rs.getString("deviceid"));
            deviceKvHistoryModel.setProperty(rs.getString("property"));
            deviceKvHistoryModel.setValue(rs.getString("value"));

            return deviceKvHistoryModel;
        }

}
